package com.sf.osms.dep.processor.parser;

import java.io.File;
import java.util.List;

import com.sf.osms.dep.domain.Agent;
import com.sf.osms.dep.domain.Handover;
import com.sf.osms.dep.domain.Router;
import com.sf.osms.dep.processor.exception.RouterException;
import com.sf.osms.dep.processor.model.EventModel;
import com.sf.osms.dep.processor.model.XmlRecord;
import com.sf.osms.dep.processor.util.HandoverLine;
import com.sf.osms.dep.processor.util.XMLParserUtils;

public class XmlEventParser implements EventParser<XmlRecord, Router> {

	@Override
	public EventModel<XmlRecord, Router> parse(File file, Agent agentInfo)
			throws RouterException {
		
		EventModel<XmlRecord,Router> eventModel = new EventModel<XmlRecord,Router>();
		
		List<XmlRecord> xmlTobean = null;
		try {
			xmlTobean = XMLParserUtils.xmlTobean(file, "//CONSIGNMENT",XmlRecord.class);
		} catch (Exception e) {
			throw new RouterException("parse xml document occur exception");
		}
		
		eventModel.setRecordList(xmlTobean);
		eventModel.setFile(file);
		return eventModel;
	}

	@Override
	public EventModel<HandoverLine, Handover> parseHandovers(File file,
			Agent agentInfo) throws RouterException {
		// TODO Auto-generated method stub
		return null;
	}
}
